<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="/view/common/common.jsp"%>


	<script type="text/javascript">
		function searchData() {
			$('#tab').datagrid('load',serializeForm($('#mySearchForm')));
		}

		function formatData(val, row) {
			if (val == '0') {
				return '未使用';
			} else {
				return '已使用';
			}
		}

		function add() {
			$("#system_user_addDialog").dialog({
				modal : true,
				iconCls : 'icon-add',
				title : '发送信息',
				width : 360,
				cache : false,
				shadow:false,
				closed : false
			});

		}


		function saveOrUpDate() {
			var	url ='${ctx}/message/add.do';
			$("#system_user_addForm").form('submit', {
				url : url,
				onSubmit : function() {
					if ($(this).form('validate') == false) {
						return false;
					}
					return true;
				},
				success : function(result) {
					var result = eval('(' + result + ')');
					if (result.isSuc) {
						$.messager.alert('消息', result.msg, 'info');
						$("#system_user_addDialog").dialog("close");
						$('#tab').datagrid('reload');
					} else {
						$.messager.alert('错误', result.msg, 'error');
					}
				}
			});
		}

	</script>

</head>
<body>

<div class="easyui-panel" fit="true">
	<div id="jqueryToolbar" style="padding:auto;height:auto">
		<%--<div style="margin-top:5px; padding-bottom:8px; border-bottom:1px solid #ccc;">--%>
			<%--<form id="mySearchForm" action="" method="Post">--%>

						<%--手机:	<input type="text" id="phone" name="phone" class="easyui-textbox"  style="width: 140px; height: 25px;"/>--%>
						<%--<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="searchData()">查询</a>--%>
			<%--</form>--%>
		<%--</div>--%>
	</div>

	<div id="system_user_list_tb" style="height: auto; padding-left: auto;">
	 	<c:if test="${SESSION_INFO_OBJECT.type==0}">
	 		<a href="#" class="easyui-linkbutton" onclick="add()" data-options="iconCls:'icon-add',plain:true">发送信息</a>
	 	</c:if>	
	</div>

	<table id="tab" class="easyui-datagrid" fit="true" style="height:370px;width:auto" url="${ctx}/message/getAll.do"
		   rownumbers="true" pagination="true" pagePosition="top" singleSelect="true"  toolbar="#system_user_list_tb" >
		<thead>
		<tr>
			<th field="title" width="130" align="center">标题</th>
			<th field="content" width="130" align="center">内容</th>
			<th field="createTime"  width="130" align="center">创建时间</th>
		</tr>
		</thead>
	</table>


	<!-- 添加 ------------start -->
	<div id="system_user_addDialog"  class="easyui-dialog"  data-options="closed:true"  buttons="#addButs1">
		<form id="system_user_addForm" method="post">
			<table style="margin: 10px 30px;">
				<tr>
					<td style="text-align: right;">标题:</td>
					<td><input type="text" id="title" name="title"      style="width: 200px; height: 25px;" class="easyui-textbox"  data-options="required:true,missingMessage:'为必填项'"  ></td>
				</tr>
				<tr>
					<td style="text-align: right;">内容:</td>
					<td>
						<input type="text" id="content" name="content"      style="width: 200px; height: 100px;" class="easyui-textbox"  data-options="required:true,missingMessage:'为必填项'"  >
						<%--<textarea id="content" name="content"  data-options="multiline:true" style="width: 300px; height: 80px;"   class="easyui-textbox" data-options="required:true,missingMessage:'为必填项'" ></textarea>--%>
					</td>
				</tr>
			</table>
		</form>
		<div id="addButs1"  >
			<a href="#" class="easyui-linkbutton"   onclick="saveOrUpDate()"   style="width:80px;height:30px;" iconCls="icon-ok" >发送</a>
		</div>
	</div>
	<!-- 添加 ------------end -->

</div>


</body>
</html>
